# -*- coding: utf-8 -*-
# @Time    : 2021/10/24 9:25
# @Author  : super

import socket

if __name__ == '__main__':

	#创建TCP链接
	tcp_client_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
	#链接到服务端
	tcp_client_socket.connect(("192.168.31.9", 9091))
	#往服务端发送数据
	for i in range(0,3):
		tcp_client_socket.send("发送一条数据给服务端".encode("gbk"))
	#接收服务端发送过来的数据
	while True:
		recv_data = tcp_client_socket.recv(1024)
		print(recv_data.decode("gbk"))
		print(len(recv_data))
		if len(recv_data) == 1:
			#关闭链接
			tcp_client_socket.close()